package com.csnt.dblocation.httpclient;

import java.util.Objects;

public class JsonResult<T> {

    private int code;//状态码
    private String msg;//错误码
    private T data;//相应具体的数据类型
    private T other;

    public JsonResult(int statusCode, String msg, T data, T other) {
        this.code=statusCode;
        this.msg=msg;
        this.data=data;
        this.other=other;

    }

    //省略构造方法和 getting，setting 方法


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public T getOther() {
        return other;
    }

    public void setOther(T other) {
        this.other = other;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof JsonResult)) return false;
        JsonResult<?> that = (JsonResult<?>) o;
        return getCode() == that.getCode() &&
                Objects.equals(getMsg(), that.getMsg()) &&
                Objects.equals(getData(), that.getData()) &&
                Objects.equals(getOther(), that.getOther());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getCode(), getMsg(), getData(), getOther());
    }


    @Override
    public String toString() {
        return "JsonResult{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                ", other=" + other +
                '}';
    }
}